﻿// myGame-alpha.js
//
// This file contains the code for a sample game using the doors engine.
//
// Released under the Apache 2.0 license on http://code.google.com/p/doors-engine/.
//////////////////////////////////////


function startGame()
{
	// Define game data.
	// TODO: Load dynamically from server?
	
	// Define a room.
	var englishTavern = new DRoom("English tavern", "images/rooms/room1.jpg", "images/rooms/room1_Depth.png",
		[	new DObject("room1_CarriageBushesLeft", "images/objects/room1_CarriageBushesLeft.png", null, null, null, 0, 330, 50),
			new DObject("room1_BushesRight", "images/objects/room1_BushesRight.png", null, null, null, 551, 396, 20),
			new DObject("room1_Cart", "images/objects/room1_Cart.png", null, null, null, 490, 364, 130),
			new DObject("room1_DistantCart", "images/objects/room1_DistantCart.png", null, null, null, 598, 289, 150)
		]);
	
	// Define another room (this one is not as interesting).
	var uglyParis = new DRoom("Ugly Paris", "images/rooms/Paris_ugly.jpg", null,
		[
		]);
	
	// Define a door, with an 'onclick' function that will handle the room transition.
	var englishTavernDoor = new DObject("room1_Door", null, "images/objects/room1_DoorMask.png", {"red": 43, "green": 80, "blue": 57}, "Door", 509, 326, null);
	englishTavernDoor.onclick = function(clickEventInfo) {
		doorsGoToRoom(uglyParis);
	};
	englishTavern.objects.push(englishTavernDoor);
	
	// Define a character. //TODO: Actually do something with this...
	//var character1Definition = 
	//{
	//	"name": "Edmund Dantes"
	//};
	
	// Load the rooms. TODO: Support on-demand loading during room changes?
	englishTavern.load();
	uglyParis.load();
	
	// Start in the first room.	
	doorsGoToRoom(englishTavern);
	
	// Start the game loop.
	doorsStart();
}

function stopGame()
{
	// Stop the game loop.
	doorsStop();
}